package com.diy.sigmund.diyorder.test.controller;

import com.diy.sigmund.diycommon.entity.ResultMsg;
import com.diy.sigmund.diycommon.spring.anno.IgnoreTokenVerification;
import com.diy.sigmund.diyorder.feign.client.UserClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <br>Feign传输Multipartfile文件
 * <br>Feign文件传输
 *
 * @author ylm-sigmund
 * @since 2022/5/1 9:38
 */
@RestController
@RequestMapping
public class FileUploadFeignController {

    @Autowired
    private UserClient userClient;
    private static final Logger log = LoggerFactory.getLogger(FileUploadFeignController.class);

    @IgnoreTokenVerification
    @PostMapping(value = "/order/testFileUploadFeign", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResultMsg testFileUploadFeign(@RequestPart("file") MultipartFile file,
            @RequestPart("file1") MultipartFile file1,
            @RequestParam String name,
            @RequestParam String phone) {
        log.info("name:{},phone:{}", name, phone);
        log.info("getOriginalFilename:{}", file.getOriginalFilename());
        return userClient.receiveFile(file, file1, name, phone);
    }
}
